package com.zxl.service.impl;

import com.zxl.service.SmsService;
import com.zxl.utils.HttpUtils;
import com.zxl.vo.Sms;
import org.apache.http.HttpResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @packageName com.zxl.service.impl
 * @ClassName
 * @Author zxl
 * @Description //TODO
 * @date
 **/
@Service
public class SmsServiceImpl implements SmsService {

    @Value("${sms.host}")
    private String host;

    @Value("${sms.path}")
    private String path;

    @Value("${sms.appcode}")
    private String appcode;

    @Value("${sms.templateId}")
    private String templateId;

    @Override
    public void send(Sms sms) {

        Map<String, String> headers = new HashMap<String, String>();

        headers.put("Authorization", "APPCODE " + appcode);
        Map<String, String> querys = new HashMap<String, String>();
        querys.put("mobile", sms.getPhone());
        querys.put("templateId", "M72CB42894");
        querys.put("value", sms.getCode());
        Map<String, String> bodys = new HashMap<String, String>();


        try {
            //HttpResponse response = HttpUtils.doPost(host, path, "POST", headers, querys, bodys);
            //System.out.println(response.toString());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
